const {createProxyMiddleware } = require("http-proxy-middleware");

let target = 'http://172.16.5.184:8000'

module.exports = function (app) {
  console.log('app.........................', process.env.REACT_APP_ENV);
  if(process.env.REACT_APP_ENV === 'mock') {
    target = 'http://127.0.0.1:4000'
  }
  app.use(
    createProxyMiddleware('/api/', {
      target, 
      changeOrigin: true,
      pathRewrite: {
        '^/api': ''
      }
    })
  )
};